﻿namespace EyeOpen.Mvc.Modules
{
	using System;
	using System.Web;

	public class CachePreventHttpModule : IHttpModule
	{
		public void Init(HttpApplication context)
		{
			context.EndRequest += EndRequest;
		}

		public void Dispose()
		{
		}

		private void EndRequest(object sender, EventArgs e)
		{
			var application = (HttpApplication)sender;
			var context = application.Context;

			context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-100);
			context.Response.AddHeader("pragma", "no-cache");
			context.Response.AddHeader("cache-control", "private");
			context.Response.CacheControl = "no-cache";
		}
	}
}